<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Controller;

use App\Constants\ErrorCode;
use App\Service\AdvertService;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\Utils\Context;

class AdvertController extends AbstractController
{
    /**
     * @todo 处理广告业务
     *
     */
    public function index(RequestInterface $request)
    {
        $descryptData = $request->getAttribute("descrypt_data");
        $appId = $request->input("app_id");

        $rs = AdvertService::advert($descryptData,$appId);
        $code = ErrorCode::ADVER_ADD_ERR;

        if ($rs){
           $code = ErrorCode::ADVER_ADD_SUCC;
        }

        return $this->returncode($code,$appId,ErrorCode::getMessage($code));
    }

}
